package com.java.demo;

import com.java.demo.component.BeanCompont;
import com.java.demo.controller.UserController;
import com.java.demo.controller.UserController2;
import com.java.demo.entity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        /*ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        UserController controller = context.getBean("userController", UserController.class);
        controller.printUser();

        UserController2 controller2 = context.getBean("userController2", UserController2.class);
        controller2.printUser2();*/
        // 获取 Spring 上下文
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        // 获取 Bean 对象
        BeanCompont compont = context.getBean("beanCompont", BeanCompont.class);
        // 使用 Bean
        compont.sayHi();
        // 执行销毁
        context.destroy();
    }
}
